package team.sun.sss.common.domain.custom;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import team.sun.sss.common.domain.StringUtils;
import team.sun.sss.common.entity.Clothing;
import team.sun.sss.common.entity.NewStudentEntity;
import team.sun.sss.common.entity.StudentEntity;
import team.sun.sss.common.service.StudentConService;

import java.util.ArrayList;
import java.util.List;

import static team.sun.sss.common.domain.Constants.UNIFORM;
import static team.sun.sss.common.domain.Constants.UNIFORM_SHOES;

@Component
public class Custom {
    @Autowired
    private StudentConService studentConService;
    public  List<Clothing> getClothData()
    {
        List<Clothing> clothing=new ArrayList<>();
        for (int i = 0; i <UNIFORM.length ; i++) {
            Clothing clothing1=new Clothing();
            clothing1.setFlag(false);
            clothing1.setName(UNIFORM[i]);
            clothing.add(clothing1);
        }
        return clothing;
    }
    public  List<Clothing> getShoesData()
    {
        List<Clothing> clothing=new ArrayList<>();
        for (int i = 0; i <UNIFORM_SHOES.length ; i++) {
            Clothing clothing1=new Clothing();
            clothing1.setFlag(false);
            clothing1.setName(UNIFORM_SHOES[i]);
            clothing.add(clothing1);
        }
        return clothing;
    }
    public List<Clothing> setClothData( NewStudentEntity studentEntity){
        List<Clothing> clothing=getClothData();
        if(StringUtils.isNotEmpty(studentEntity.getNewStuShit()))
        {
            for (int i = 0; i <clothing.size() ; i++) {
                 if(studentEntity.getNewStuShit().equals(clothing.get(i).getName()))
                 {
                     clothing.get(i).setFlag(true);
                 }
            }
        }
        return clothing;

    }


    public List<Clothing> setShoesData( NewStudentEntity studentEntity){
        List<Clothing> clothing=getShoesData();
        if(StringUtils.isNotEmpty(studentEntity.getNewStuShoes()))
        {
            for (int i = 0; i <clothing.size() ; i++) {
                if(studentEntity.getNewStuShoes().equals(clothing.get(i).getName()))
                {
                    clothing.get(i).setFlag(true);
                }
            }
        }
        return clothing;

    }

    public List<Clothing> setShitData( NewStudentEntity studentEntity){
        List<Clothing> clothing=getClothData();
        if(StringUtils.isNotEmpty(studentEntity.getNewStuShit()))
        {
            for (int i = 0; i <clothing.size() ; i++) {
                if(studentEntity.getNewStuShit().equals(clothing.get(i).getName()))
                {
                    clothing.get(i).setFlag(true);
                }
            }
        }
        return clothing;

    }

    public int getChecked(){
        QueryWrapper<StudentEntity> studentEntityQueryWrapper=new QueryWrapper<>();
        studentEntityQueryWrapper.eq("state",1);
        studentEntityQueryWrapper.eq("del_flag",0);
       return studentConService.list(studentEntityQueryWrapper).size();
    }

    public int getNotChecked(){
        QueryWrapper<StudentEntity> studentEntityQueryWrapper=new QueryWrapper<>();
        studentEntityQueryWrapper.eq("state",0);
        studentEntityQueryWrapper.eq("del_flag",0);
        return studentConService.list(studentEntityQueryWrapper).size();
    }
}
